import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/6 10:43
 */

public class Solution {
    public int countBattleships(char[][] board) {
        int count = 0, m = board.length, n = board[0].length;
        if (board == null || m == 0 || n == 0) {
            return 0;
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (board[i][j] == 'X') {
                    // 判断是否为战舰的头部
                    boolean isHead = true;

                    // 检查左边
                    if (j > 0 && board[i][j - 1] == 'X') {
                        isHead = false;
                    }

                    // 检查上边
                    if (i > 0 && board[i - 1][j] == 'X') {
                        isHead = false;
                    }

                    if (isHead) {
                        count++;
                    }
                }
            }
        }

        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int m = in.nextInt(), n = in.nextInt();
            in.nextLine();
            char[][] board = new char[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    board[i][j] = in.nextLine().charAt(0);
                }
            }
            Solution solution = new Solution();
            System.out.println(solution.countBattleships(board));
        }
    }
}